package com.hiray.demos.entry

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.webkit.WebViewClient
import com.hiray.demos.R
import kotlinx.android.synthetic.main.activity_web_view.*

class WebViewActivity : AppCompatActivity() {


    companion object {
        private val URL_KEY = "URLKEY"

        fun openUrl(context: Context, url: String) {

            var intent = Intent(context, WebViewActivity::class.java)
            intent.putExtra(URL_KEY, url)
            context.startActivity(intent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_web_view)
        var settings = webview.settings
        val url = intent.getStringExtra(URL_KEY)
        settings.javaScriptEnabled = true
        settings.useWideViewPort = true
        webview.webViewClient = WebViewClient()
        webview.loadUrl(url)
    }
}
